package com.xintonghua.bussiness.ui.fragment.client;

import android.app.Activity;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.xintonghua.base.adapter.BaseAdapter;
import com.xintonghua.bussiness.R;
import com.xintonghua.bussiness.bean.CustomersListItemBean;
import com.xintonghua.bussiness.ui.view.CircleImageView;
import com.xintonghua.bussiness.util.GlideUtils;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by liqi on 2018/3/30.
 */

public class CustomersListAdapter extends BaseAdapter<CustomersListItemBean, CustomersListAdapter.ClientViewHolder> {
    Context context;

    public CustomersListAdapter(Activity mActivity, List<CustomersListItemBean> list) {
        super(mActivity, list);
        context = (Context) mActivity;
    }

    @Override
    public ClientViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = inflater.inflate(R.layout.adapter_customers_list_item, parent, false);
        return new ClientViewHolder(view);
    }

    @Override
    public void onBindViewHolder(ClientViewHolder holder, int position) {
        CustomersListItemBean bean = list.get(position);

        GlideUtils.load(context, holder.ivHead, bean.getImg());
        holder.tvUsername.setText(""+bean.getName());
        holder.tvGuke.setText("顾客:"+bean.getCustomerName());
        holder.tvContent.setText(""+bean.getNote());
        holder.tvLevel.setText(bean.getLv()+"级");
        holder.tvTime.setText(""+bean.getCreate_time());
    }

    class ClientViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.iv_head)
        CircleImageView ivHead;
        @BindView(R.id.tv_username)
        TextView tvUsername;
        @BindView(R.id.tv_mtype)
        TextView tvMtype;
        @BindView(R.id.tv_guke)
        TextView tvGuke;
        @BindView(R.id.tv_level)
        TextView tvLevel;
        @BindView(R.id.tv_content)
        TextView tvContent;
        @BindView(R.id.tv_time)
        TextView tvTime;

        public ClientViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }

}
